/**
 * 这里存放的是对 AskList 的操作。
 */
import { ajaxTcbCloud } from "@/utils/cloud";
import { successResponseType, failRejectType } from "CustomTypes";

/**
 * 获取装修咨询提交的所有留言。
 */
export const reqAskListMessages = (
  page = 1,
  size = 20
): Promise<successResponseType | failRejectType> =>
  ajaxTcbCloud("/ask/messages", { page, size });
/**
 * 获取装修种类的名字。
 */
export const reqAskTypes = (): Promise<successResponseType | failRejectType> =>
  ajaxTcbCloud("/ask/types", {}, false);
/**
 * 搜索装修咨询分页列表
 *
 * @param page
 * @param size
 * @param searchType
 * @param searchKeyWord
 */
export const reqSearchAskListMessages = ({
  page,
  size,
  searchType,
  searchKeyWord,
  status,
  type
}: any): Promise<successResponseType | failRejectType> =>
  ajaxTcbCloud("/ask/getMessageBoard", {
    page,
    size,
    [searchType]: searchKeyWord,
    status,
    type
  });
/**
 * 更新装修咨询的状态
 * @param data
 */
export const reqUpdateAskMessageStatus = (
  _id: string,
  status: string
): Promise<successResponseType | failRejectType> =>
  ajaxTcbCloud("/ask/updateStatus", { _id, status }, false);
